//
//  WSRewardCell.m
//  LANGirl
//
//  Created by 吴帅 on 16/4/1.
//
//

#import "WSRewardCell.h"

@interface WSRewardCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UIImageView *arrowImage1;
@property (nonatomic, strong) UIImageView *arrowImage2;
@property (nonatomic, strong) UIButton *contentBtn;
@property (nonatomic, strong) UIButton *moneyBtn;

@end

@implementation WSRewardCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:(CGRect)frame];
    if (self) {
        [self createSubView];
    }
    
    return self;
}

- (void)createSubView {
    
    //名字
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.font = [UIFont fontWithName:ZIXING size:TEXTCONTENTFONT*TEXTWEIGHT];
    self.titleLabel.textColor = HS;
    [self.contentView addSubview:_titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.left.mas_equalTo(15.00 * AUTO_WIDTH);
    }];
    
    self.arrowImage1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"addCV_arrow"]];
    [self.contentView addSubview:_arrowImage1];
    [self.arrowImage1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.right.mas_equalTo(-21.00*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(10.00*AUTO_WIDTH, 5.00*AUTO_WIDTH));
    }];
    
    //
    self.contentLabel = [[UILabel alloc] init];
    self.contentLabel.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT*TEXTWEIGHT];
    self.contentLabel.textColor = TextLightGrayColor;
    self.contentLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_contentLabel];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.arrowImage1.mas_left).offset(-3.00*AUTO_WIDTH);
        
    }];
    
    self.contentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:_contentBtn];
    self.contentBtn.titleLabel.font = [UIFont fontWithName:ZIXING size:TEXTCONTENTFONT*TEXTWEIGHT];
    [self.contentBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.contentBtn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.right.mas_equalTo(@0);
        make.width.mas_equalTo(@100);
    }];
    
    //money
    self.moneyLabel = [[UILabel alloc]init];
    self.moneyLabel.font = [UIFont fontWithName:@"Arial" size:TEXTALITTLEFONT*TEXTWEIGHT];
    self.moneyLabel.text = @"0元";
    self.moneyLabel.textColor = TextLightGrayColor;
    self.moneyLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_moneyLabel];
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.center.equalTo(self.contentView);
    }];
    
    self.arrowImage2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"addCV_arrow"]];
    [self.contentView addSubview:_arrowImage2];
    [self.arrowImage2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.moneyLabel.mas_right).offset(3 * AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(10.00*AUTO_WIDTH, 5.00*AUTO_WIDTH));
    }];
    
    self.moneyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:_moneyBtn];
    [self.moneyBtn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.moneyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.centerX.mas_equalTo(@0);
        make.width.mas_equalTo(@100);
    }];
}

- (void)buttonAction:(UIButton *)btn {

    if ([btn isEqual:self.contentBtn]) {
        [self.delegate buttonClickWith:BUTTONCLICKCONTENT label:self.contentLabel];
    } else {
        [self.delegate buttonClickWith:BUTTONCLICKMONEY label:self.moneyLabel];
    }
}

- (void)setNameStr:(NSString *)nameStr {

    _nameStr = nameStr;
    self.titleLabel.text = _nameStr;
}

- (void)setContentStr:(NSString *)contentStr {

    _contentStr = contentStr;
    _contentLabel.text = _contentStr;
}

@end
